package com.mvc.web.order.controller.validate;

import org.springframework.stereotype.Repository;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.mvc.web.common.utils.ToolsUtils;
import com.mvc.web.order.vo.FileVo;



@Repository
public class FileVoValidator implements Validator{

	@Override
	public boolean supports(Class<?> clazz) {
		return FileVoValidator.class.equals(clazz);
	}

	@Override
	public void validate(Object obj, Errors es) {
		FileVo vo = (FileVo) obj;
		if(vo.getOrderId() == null){
			es.reject("1002", "订单id不能为空");return;
		}
		if(vo.getFileType() == null){
			es.reject("1002", "文件类型不能为空");return;
		}
		if(ToolsUtils.isEmpty(vo.getFileName())){
			es.reject("1002", "文件名称不能为空");return;
		}
		if(vo.getMaterialType()==null){
			es.reject("1002", "材料类型不能为空");return;
		}
	}

}
